package cn.service;

import cn.dto.Query;
import cn.entity.*;
import cn.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PageService{
    //学术活动
    @Autowired
    private AcademicActivityMapper academicActivityMapper;
    //学术奖励
    @Autowired
    private AcademicAwardsMapper academicAwardsMapper;
    //轮播图
    @Autowired
    private BannerMapper bannerMapper;
    //联系我们
    @Autowired
    private ContactMapper contactMapper;
    //合作研究
    @Autowired
    private CooperationMapper cooperationMapper;
    //课题组简介
    @Autowired
    private IntroductionMapper introductionMapper;
    //实验设备
    @Autowired
    private MachineMapper machineMapper;
    //团队成员
    @Autowired
    private MemberMapper memberMapper;
    //团队成员信息
    @Autowired
    private MemberMsgMapper memberMsgMapper;
    //组内动态
    @Autowired
    private NewsMapper newsMapper;
    //论文
    @Autowired
    private PaperMapper paperMapper;
    //研究内容
    @Autowired
    private ResearchMapper researchMapper;
    //子菜单
    @Autowired
    private SubMenuMapper subMenuMapper;

    public List<Banner> getBannerList(int count) {
        return bannerMapper.selectBannerList(new Query(1,count));
    }

    public List<News> getNewsList(int count) {
        return newsMapper.selectNewsList(new Query(1,count));
    }

    public Introduction getIntroduction() {
        return introductionMapper.selectIntroduction();
    }

    public List<SubMenu> getSubMenuList(String menu) {
        return subMenuMapper.selectSubMenuListByMenu(menu);
    }

    public List<Member> getMemberListByMenuId(String menuId, Query query) {
        return memberMapper.selectMemberListByMenuId(Integer.valueOf(menuId),query);
    }

    public Member getMember(String id) {
        return memberMapper.selectByPrimaryKey(Integer.valueOf(id));
    }

    public List<MemberMsg> getMemberMsgByMemId(String id) {
        return memberMsgMapper.selectByMemberId(Integer.valueOf(id));
    }

    public List<Machine> getMachineList(Query query) {
        return machineMapper.getMachineList(query);
    }

    public Machine getMachine(String id) {
        return machineMapper.selectByPrimaryKey(Integer.valueOf(id));
    }

    public List<News> getNewsList(Query query) {
        return newsMapper.selectNewsList(query);
    }

    public List<Paper> getPaperListByYear(Query query, String year) {
        query.setSearch(year);
        return paperMapper.selectPaperListByYear(query);
    }

    public Contact getContactByMenuId(String menuId) {
        return contactMapper.selectContactByMenuId(Integer.valueOf(menuId));
    }

    public Research getResearchByMenuId(String menuId) {
        return researchMapper.selectResearchByMenuId(Integer.valueOf(menuId));
    }

    public AcademicAwards getAwardsByMenuId(String menuId) {
        return academicAwardsMapper.selectAwardsByMenuId(Integer.valueOf(menuId));
    }

    public List<AcademicActivity> selectAcademicList(Query query) {
        return academicActivityMapper.selectAcademicList(query);
    }

    public List<Cooperation> selectCooperationList(Query query) {
        return cooperationMapper.selectCooperationList(query);
    }

    public List<Integer> getPublicationsYearList() {
        return paperMapper.getPublicationsYearList();
    }
}
